
import java.awt.event.*;     
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTextPane;

import javax.swing.KeyStroke;
import javax.swing.undo.UndoManager;

/**
 * This object that extends JMenu is order to instantiate a menu called "Edit", which
 * involves "Copy","Cut","Paste","Delete","Select All" and "Find/Replace" functions
 * @author Group 3, Zou Longhao.
 */
public class EditorAction{     
       
        public void myAction(JMenuItem e, JTextPane text){
        	if(e.getText()=="Copy")	//copied and stored in clipboard. 
        	{   
        		text.copy();
            }   
            else if(e.getText()=="Cut")	//cut and stored in clipboard.  
            {    
            	text.cut();  
            }   
            else if(e.getText()=="Paste")   //paste from clipboard.   
            {   
            	text.paste();
            }
            else if(e.getText()=="Delete"){	//delete the selected content.
            	text.replaceSelection("");
            }
            else if(e.getText()=="Select All"){ //select all
            	text.setSelectionStart(0);
				text.setSelectionEnd(text.getText().length());
            }
            else if(e.getText()=="Find/Replace"){ //call the FindAndReplace object        
            	FindAndReplace fr=new FindAndReplace(text);
            } 
        	
        }
  }
